<template>
  <div class="list-block">
    <div class="nice">
      <span class="title">最受好评的电影</span>
      <div class="hot">
        <div v-for="(item, key) in reying" class="hotMovie" :key="key">
          <img :src="item.img" alt="" />
          <span class="movie-nm">{{ item.nm }}</span>
        </div>
      </div>
    </div>
    <router-link
      class="list"
      v-for="item in reying"
      :key="item.id"
      :to="'/item/' + item.id"
    >
      <div class="list-imgBlock">
        <img class="list-img" v-lazy="item.img" alt="" />
      </div>
      <div class="list-msg">
        <div class="list-msg-left">
          <p>{{ item.nm }}</p>
          <p v-if="item.globalReleased && item.sc !== 0">
            观众评
            <span class="score">{{ item.mk }}</span>
          </p>
          <p v-else-if="item.globalReleased">{{ item.scoreLabel }}</p>
          <p v-else>
            <span class="score">{{ item.wish }}</span
            >人想看
          </p>
          <p>{{ item.desc }}</p>
          <p>{{ item.showInfo }}</p>
        </div>
        <div class="list-msg-right">
          <button
            class="list-buy"
            :style="{ 'background-color': item.showStateButton.color }"
          >
            {{ item.showStateButton.content }}
          </button>
        </div>
      </div>
    </router-link>
  </div>
</template>
<script>
export default {
  name: "movie",
  data() {
    return {
      reying: [],
    };
  },
  mounted() {
    this.$axios
      .get(
        "/api/mmdb/movie/v3/list/hot.json?ct=%E6%B7%B1%E5%9C%B3&ci=30&channelId=4"
      )
      .then((res) => {
        res.data.data.hot.forEach((item) => {
          item.img = item.img.replace("w.h", "128.180"); //64*90
        });
        this.reying = res.data.data.hot;
      });
  },
  methods: {
    tap(id) {
      this.$router.push({
        path: "/item/" + id,
      });
    },
  },
};
</script>

<style scoped>

a {
  text-decoration: none;
}

.list-block {
  background-color: #f5f5f5;
}

.nice {
  padding: .266667rem .4rem;
  background-color: #fff;
  margin-bottom: .4rem;
  padding-bottom: .533333rem;
}

.title {
  font-size: 0.373rem;
}

.hotMovie {
  display: flex;
  flex-direction: column;
  margin-right: 0.213rem;
  flex: 1 1 auto;
}

.hotMovie img {
  width: 2.267rem;
  height: 3.067rem;
  flex: 0 0 auto;
}

.movie-nm {
  width: 2.267rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: bold;
  font-size: 0.385rem;
  margin-top: 0.133rem;
}

.hot {
  display: flex;
  overflow: auto;
  padding-top: .4rem;
}

.list-block .list {
  display: flex;
  width: 100%;
  padding: 10px 14px 0 10px;
  background-color: #fff;
}

.list-block .list .list-imgBlock {
  width: 1.8rem;
  min-width: 1.8rem;
  margin-right: 10px;
}

.list-block .list .list-imgBlock .list-img {
  width: 100%;
  object-fit: contain;
}

.list-block .list .list-msg {
  flex: 1;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
}

.list-block .list .list-msg-left {
  flex: 1;
  overflow: hidden;
  max-width: 6rem;
}

.list-block .list .list-msg-left .score {
  font-weight: 700;
  color: #faaf00;
  font-size: 0.4rem;
}

.list-block .list .list-msg-left p {
  margin-bottom: 5px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.list-block .list .list-msg-left p:nth-of-type(1) {
  font-size: 17px;
  color: #333;
  font-weight: 700;
}

.list-block .list .list-msg-left p:nth-of-type(2),
.list-block .list .list-msg-left p:nth-of-type(3),
.list-block .list .list-msg-left p:nth-of-type(4) {
  font-size: 13px;
  color: #666;
}

.list-block .list .list-msg-right {
  display: flex;
  min-width: 50px;
}

.list-block .list .list-msg-right .list-buy {
  margin: auto;
  width: 1.44rem;
  height: 0.747rem;
  color: #fff;
  white-space: nowrap;
  font-size: 0.26rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.5rem;
  border: 0;
}
</style>
